package com.example.qxfw.ybzz.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.qxfw.common.entity.qx.ThirtyYearDayStatics;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
@DS("qx")
public interface ThirtyYearDayStaticsMapper {

    @Select("select sum(yearareadayrain) AS yearareadayrain " +
            "from thirtyyear_day_statics " +
            "where StationId = #{stationId} and DayIndex between #{startDays} and  #{endDays} ")
    String selectRain(String stationId,Integer startDays,Integer endDays);

    @Select("select sum(yearareadayrain) AS yearareadayrain " +
            "from thirtyyear_day_statics " +
            "where StationId =#{stationId} and( (DayIndex between 1 and  #{endDays}) or (DayIndex between #{startDays} and  '365' ) ) ")
    String selectRain2(String stationId,Integer startDays,Integer endDays);

    @Select("select avg(yearAreadayavgtemp) AS yearAreadayavgtemp " +
            "from thirtyyear_day_statics " +
            "where StationId = #{stationId} and DayIndex between #{startDays} and  #{endDays} ")
    String selectAvgTemp3(String stationId,Integer startDays,Integer endDays);

    @Select("select avg(yearAreadayavgtemp) AS yearAreadayavgtemp " +
            "from thirtyyear_day_statics " +
            "where StationId =#{stationId} and( (DayIndex between 1 and  #{endDays}) or (DayIndex between #{startDays} and  '365' ) ) ")
    String selectAvgTemp4(String stationId,Integer startDays,Integer endDays);

    @Select("select max(yearAreadayavgmaxtemp) AS yearAreadayavgmaxtemp " +
            "from thirtyyear_day_statics " +
            "where StationId = #{stationId} and DayIndex between #{startDays} and  #{endDays} ")
    String selectMaxTemp3(String stationId,Integer startDays,Integer endDays);

    @Select("select max(yearAreadayavgmaxtemp) AS yearAreadayavgmaxtemp " +
            "from thirtyyear_day_statics " +
            "where StationId =#{stationId} and( (DayIndex between 1 and  #{endDays}) or (DayIndex between #{startDays} and  '365' ) ) ")
    String selectMaxTemp4(String stationId,Integer startDays,Integer endDays);

    @Select("select min(yearAreadayavgmintemp) AS yearAreadayavgmintemp " +
            "from thirtyyear_day_statics " +
            "where StationId = #{stationId} and DayIndex between #{startDays} and  #{endDays} ")
    String selectMinTemp3(String stationId,Integer startDays,Integer endDays);

    @Select("select min(yearAreadayavgmintemp) AS yearAreadayavgmintemp " +
            "from thirtyyear_day_statics " +
            "where StationId =#{stationId} and( (DayIndex between 1 and  #{endDays}) or (DayIndex between #{startDays} and  '365' ) ) ")
    String selectMinTemp4(String stationId,Integer startDays,Integer endDays);

    @Select("select avg(yearareadayrain) as yearareadayrain " +
            "from  thirtyyear_day_statics " +
            "where dayindex  between '${time1}' and '${time2}' and  stationid ='${stationId}'and yearareadayrain!='-65535' ")
    String selectAvgRain(String time1,String time2, String stationId);

    @Select("select avg(yearAreadayavgtemp) AS yearAreadayavgtemp " +
            "from thirtyyear_day_statics ")
    List<String> selectAvgtemp();


    @Select("select max(yearAreadayavgmaxtemp) AS yearAreadayavgmaxtemp " +
            "from thirtyyear_day_statics")
    List<String> selectMaxTemp();

    @Select("select min(yearAreadayavgmintemp) AS yearAreadayavgmintemp " +
            "from thirtyyear_day_statics")
    List<String> selectMinTemp();

    @Select("select avg(yearareadayavgtemp) as yearareadayavgtemp " +
            "from thirtyyear_day_statics " +
            "where dayindex  between '{0}' and '{1}' and  stationid ='{2}' and yearareadayavgtemp!='-65535' ")
    String selectAvgTemp1(String time1,String time2,String stationId);

    @Select("select avg(yearareadayavgwindv) as yearareadayavgwindv " +
            "from thirtyyear_day_statics " +
            "where dayindex  between '${time1}' and '${time2}' and  stationid ='${stationId}' and yearareadayavgwindv!='-65535' ")
    String selectAvgWindVelocity(String time1,String time2,String stationId);

    @Select("select max(yearareadayavgmaxtemp) as yearareadayavgmaxtemp " +
            "from thirtyyear_day_statics " +
            "where dayindex  between '${time1}' and '${time2}' and  stationid ='${stationId}' and yearareadayavgmaxtemp!='-65535' ")
    String selectMaxTemp1(String time1,String time2,String stationId);

    @Select("select min(MinTemp) as mintemp " +
            "from thirtyyear_day_statics " +
            "where dayindex  between '${time1}' and '${time2}' and  stationid ='${stationId}' and yearareadayavgmintemp!='-65535")
    String selectMinTemp1(String time1,String time2,String stationId);

    @Select("select avg(yearareadayrain) as yearareadayrain " +
            "from thirtyyear_day_statics " +
            "where  dayindex  between '${time1}' and '${time2}' and  stationid ='${stationId}'and yearareadayrain!='-65535' ")
    String selectAvgRain1(String time1,String time2,String stationId);

    @Select("select avg(yearareadayrain) as yearareadayrain " +
            "from thirtyyear_day_statics " +
            "where ((dayindex between 1 and #{day1}) or (dayindex between #{day2} and 365)) and stationid = '${stationId}' ")
    String selectAvgRain2(int day1,int day2,String stationId);

    @Select("select avg(yearareadayrain) as yearareadayrain " +
            "from thirtyyear_day_statics " +
            "where  (dayindex  between '${day1}' and '${day2}') and  stationid ='${stationId}'and yearareadayrain!='-65535' ")
    String selectAvgRain3(int day1,int day2,String stationId);

    @Select("select max(yearareadayrain) as yearareadayrain " +
            "from thirtyyear_day_statics " +
            "where  dayindex  between '${day1}' and '${day2}' and  stationid ='${stationId}'and yearareadayrain!='-65535' ")
    String selectMaxRain(int day1,int day2,String stationId);

    @Select("select max(yearareadayrain) as yearareadayrain " +
            "from thirtyyear_day_statics " +
            "where ((dayindex between 1 and #{day1}) or (dayindex between #{day2} and 365)) and stationid = '${stationId}' ")
    String selectMaxRain1(int day1,int day2,String stationId);

    @Select("select avg(yearareadayavgwindv) as yearareadayavgwindv " +
            "from thirtyyear_day_statics " +
            "where dayindex  between '${time1}' and '${time2}' and  stationid ='${stationId}'and yearareadayavgwindv!='-65535'")
    String selectAvgWindV(String time1,String time2,String stationId);

    @Select("select yearareadaysunhour  " +
            "from thirtyyear_day_statics " +
            "where dayindex BETWEEN '${time1}' AND '${time2}' AND stationid = '${stationId}' and yearareadaysunhour!='-65535' ")
    List<String> selectSumHour(String time1,String time2,String stationId );

    @Select("select yearareadayavgmaxtemp, yearareadayavgmintemp  " +
            "from thirtyyear_day_statics " +
            "where dayindex='${date}' and  stationid ='${stationId}' ")
    List<ThirtyYearDayStatics> selectMaxTempMinTemp(String date,String stationId);

    @Select("select yearareadayrain " +
            "from thirtyyear_day_statics " +
            "where dayindex='${date}' and  stationid ='${stationId}' ")
    List<String> selectRain1(String date,String stationId);

    @Select("select max(YearAreaDayAvgMaxTemp) YearAreaDayAvgMaxTemp, min(YearAreaDayAvgMinTemp) YearAreaDayAvgMinTemp, avg(YearAreaDayAvgTemp) YearAreaDayAvgTemp" +
            " from thirtyyear_day_statics " +
            "where DayIndex between '${day1}' and '${day2}' and StationId = '${stationId}' ")
    List<ThirtyYearDayStatics> selectList(int day1,int day2,String stationId);

    @Select("select max(YearAreaDayAvgMaxTemp) YearAreaDayAvgMaxTemp, min(YearAreaDayAvgMinTemp) YearAreaDayAvgMinTemp, avg(YearAreaDayAvgTemp) YearAreaDayAvgTemp" +
            " from thirtyyear_day_statics " +
            "where ((dayindex between 1 and '${day1}') or (dayindex between '${day2}' and 365)) and stationid = '${stationId}' ")
    List<ThirtyYearDayStatics> selectList1(int day1,int day2,String stationId);

    @Select("select max(YearAreaDayAvgMaxTemp) YearAreaDayAvgMaxTemp, min(YearAreaDayAvgMinTemp) YearAreaDayAvgMinTemp, avg(YearAreaDayAvgTemp) YearAreaDayAvgTemp"+
            " from thirtyyear_day_statics " +
            "where (dayindex between '${day1}' and '${day2}') and stationid = '${stationId}' ")
    List<ThirtyYearDayStatics> selectList2(int day1,int day2,String stationId);


}
